package com.koron.css2.baseConfig.impl;

import com.github.pagehelper.PageInfo;
import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.mapper.BaseInvoiceTypeMapper;
import com.koron.css2.baseConfig.vo.BaseInvoiceTypeListVO;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

public class BaseInvoiceTypeList implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		
		@SuppressWarnings("rawtypes")
		MessageBean<PageInfo> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", PageInfo.class);
		
		BaseInvoiceTypeMapper mapper = factory.getMapper(BaseInvoiceTypeMapper.class);

		List<BaseInvoiceTypeListVO> list = mapper.selectList();
		for (BaseInvoiceTypeListVO vo : list) {
			if("0".equals(vo.getStatus())) {
				vo.setStatusName("启用");
			}else if("1".equals(vo.getStatus())){
				vo.setStatusName("停用");
			}
		}
		info.setData(new PageInfo<>(list));
		return info;
	}

}
